package com.ywj.collection.MyMap;

import java.util.HashMap;
import java.util.Map;

public class MapDemo01 {
    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        //V put(K key, V value) 将指定的值与该映射中的指定键相关联
        map.put("student1", "zhangsan");
        map.put("student2", "lisi");
        map.put("student3", "wangwu");
        map.put("student4", "zhaoliu");

//        System.out.println(map.remove("student1")); //zhangsan
//        System.out.println(map.remove("student5")); //null
//        //{student2=lisi, student4=zhaoliu, student3=wangwu}
//        System.out.println(map);

//        map.clear();
//        System.out.println(map.size() + ",  " + map);  //0,  {}

        System.out.println(map.containsKey("student1"));   //true
        System.out.println(map.containsKey("student5"));   //false
        System.out.println(map.containsValue("zhangsan")); //true
        System.out.println(map.containsValue("Jenny"));    //false

        System.out.println(map.isEmpty());  //false
        System.out.println(map.size());     //4

        System.out.println(map);

    }
}
